From 2cdf23dd60a8c630e07aebaeaa30c0cc52d7be48 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 9 Nov 2009 19:17:22 +0000 Subject: [PATCH] Remus: Do bitmap scan word-by-word before bit-by-bit. For sparse bitmaps and large domains this saves a lot of time. Signed-off-by: Brendan Cully --- tools/libxc/xc_domain_save.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c index 72ffbe6f46..30c1b6d3a4 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -94,6 +94,8 @@ struct outbuf { #define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG) +#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6) + static inline int test_bit (int nr, volatile void * addr) { return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1; @@ -1164,6 +1166,14 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, if ( completed ) { + /* for sparse bitmaps, word-by-word may save time */ + if ( !to_send[N >> ORDER_LONG] ) + { + /* incremented again in for loop! */ + N += BITS_PER_LONG - 1; + continue; + } + if ( !test_bit(n, to_send) ) continue; -- 2.30.2